<template>
	<view class="appBox">
		<!-- 邀请人 -->
		<view class="yqr">
			<text class="yqr-title">邀请人</text>
			<view class="yqr-item" v-if="myTeamData.user">
				<view class="item-left">
					<!-- <image class="left-img" :src="myTeamData.user.avatar" mode=""></image> -->
					<image class="left-img" :src="myTeamData.user.avatar" mode=""></image>
					<view class="left-txt">
						<text class="left-title">{{ myTeamData.user.nickname || ""}}</text>
						<text class="left-date">2024-03-08</text>
					</view>
				</view>
				<view class="item-right">
					<text>会员:{{ myTeamData.user.level }}</text>
				</view>
			</view>
		</view>
		<!-- 我的团队 -->
		<view class="team">
			<text class="team-title">我的团队</text>
			<view class="team-block">
				<!-- <view class="team-top">
					<text class="txt">总推单量</text>
					<text class="txt-num">{{ myTeamData.ztUserCount }} </text>
				</view> -->
				 <view class="txt textfooter" style="margin-top: 30px;font-size: 14px;">
				 	<view>
						<text>直接销售：{{ myTeamData.ztUserCount }}人</text>
					</view>
					<view>
						<text>团队总业绩：{{ userInfo.allAv }}</text> 
					</view>
				 </view> 
				
			<!-- 	 <view class="txt textfooter">
					<text>直接销售：{{ myTeamData.ztUserCount }}人</text>
					<text>A市场：{{ myTeamData.line1 }}人</text>
					<text>B市场：{{ myTeamData.line2 }}人</text>
				</view> -->
				<view class="txt" style="width: 100%;">
				    <view style="display: flex;justify-content: space-between;">
						<!-- <view>
						 	 直接销售：{{ myTeamData.ztUserCount }}人
						 </view> -->
						<!-- <view style="display: flex;">
							<view>
								<view>A市场：{{ myTeamData.line1 || 0}}人</view>
								<view>业绩：{{ myTeamData.aprice || 0 }}</view>	
							</view>	 
							<view style="margin-left: 60rpx;">
								<view>B市场：{{ myTeamData.line2 || 0}}人</view>
								<view>业绩：{{ myTeamData.bprice || 0}}</view>	
							</view>	 
						 </view> -->
					 </view>
				</view>
				
				
			</view>
		</view>
		
		<view class="team">
			<text class="team-title">我的销售团队</text>
			
			<view class="scroll-view" scroll-y="true">
				<view class="contentInfo">
				<view class="contentInfoDiv" v-for="(item,index) in ztTeamData" :key="index">
					 
					<view>
						<view class="">
							姓名：{{ item.nickname }}
						</view>
						<view class="">
							账号：{{ item.account }}
						</view>
					</view>
				</view> 
			</view>
			</view>
			
		</view>
		
		
	</view>
</template>

<script>
	const app = getApp();
	import sendVerifyCode from "@/mixins/SendVerifyCode";
	import Routine from '@/libs/routine';
	import {
		myTeam,
		loginMobile,
		registerVerify,
		getCodeApi,
		getUserInfo,
		phoneSilenceAuth,
		phoneWxSilenceAuth,
		getZPush
	} from "@/api/user";
	import {
		bindingPhone
	} from '@/api/api.js'
	import {
		getUserPhone
	} from '@/api/public';
	import mobileLogin from '@/components/login_mobile/index.vue'
	export default {
		name: 'login_mobile',
		data() {
			return {
				myTeamData: {},
				ztTeamData:[],
				page:1,
				limit:50,
				userInfo:{},
				isLoad:true
			}
		},
		components: {
			mobileLogin
		},
		mixins: [sendVerifyCode],
		mounted() {
			//this.getCode();
		},
		created() {
			this.teamData(); 
			this.getZt();
			this.getUser();
		},
		methods: { 
			getUser: function() {
				let that = this; 
				getUserInfo().then(res => {
						that.userInfo = res.data 
				});
			}, 
			async getZt() { 
				uni.showLoading({
					title: '正在加载'
				})
				let that = this;
				getZPush({page:this.page,limit:this.limit}).then((res) => {
					 if(res.data.length < 50){
						that.isLoad=false; 
					 }else{
						 that.page++
					 }
					
					that.ztTeamData = that.ztTeamData.concat(res.data)
					
					 
				}).catch((res) => {
					 
				})
			},
			async teamData() { 
				uni.showLoading({
					title: '正在加载'
				})
				myTeam().then((res) => {
					this.myTeamData = res.data
					uni.hideLoading()
				}).catch((res) => {
					this.$util.Tips({
						title: res
					});
					uni.hideLoading()
				})
			}, 
			onReachBottom() {
				if(isLoad){
					this.getZt();
				}
				
			}
		}
	}
</script>

<style>
	page {
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	.appBox {
		background-color: #F2F6FD;
		height: 100%;
		padding: 16rpx 33rpx;

		.yqr {
			margin-top: 33rpx;

			.yqr-title {
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #333333;
				display: block;
			}

			.yqr-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 114rpx;
				padding: 18rpx 22rpx 15rpx 21rpx;
				background: #fff;
				margin-top: 18rpx;

				.item-left {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.left-img {
						width: 85rpx;
						height: 85rpx;
						border-radius: 50%;
						margin-right: 29rpx;
					}

					.left-txt {
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.left-title {
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 26rpx;
							color: #333333;
						}

						.left-date {
							font-family: PingFang SC;
							font-weight: 400;
							font-size: 22rpx;
							color: #999999;
							line-height: 30rpx;
						}
					}

				}

				.item-right {
					width: 84rpx;
					height: 37rpx;
					background: rgba(208, 93, 0, 0.39);
					border-radius: 4px;
					color: #BA6C02;
					font-size: 26rpx;
				}
			}
		}

		.team {
			margin-top: 69rpx;

			.team-title {
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #333333;
				display: block;
			}

			.team-block {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 285rpx;
				background: url('/static/images/team-bg.png') no-repeat;
				background-size: 100% 100%;
				margin-top: 13rpx;
				padding: 35rpx 39rpx 32rpx 36rpx;

				.team-top {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
				}

				.txt-num {
					font-family: PingFang SC;
					font-weight: 400;
					font-size: 66rpx;
					color: #FFFFFF;
				}

				.txt {
					color: white;
					font-size: 22rpx;
				}

				.textfooter {
					display: flex;
					justify-content: space-between;
					width: 100%;
				}
			}
		}
	}

				.scroll-view { 
					.contentInfo {
						width: 100%;

						.contentInfoDiv {
							margin: 10rpx 0; 
							padding: 10rpx 20rpx;
							background-color: #fafafa;
							display: flex;

							.contentInfoName {
								margin: 0 40rpx 0 10rpx;
							}
						}
					}
				}

	page {
		background-color: #fff !important;
	}
</style>
